package com.lms.netty.tcp.protocol;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-06-18 17:58
 * @Description:
 */
public class MyMessageEncoder extends MessageToByteEncoder<MessageProtocol> {
    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, MessageProtocol msg, ByteBuf out) throws Exception {
        System.out.println("编码...");
        out.writeInt(msg.getLen());
        out.writeBytes(msg.getContent());
    }
}
